<?php
/**
 * 案例展示分类页面
 * author:wang
 */
define("PHP_IN",true);
require "include/init.php";
require ROOT_PATH."smarty_connection.php";

$caseid = isset($_GET['caseid']) ? $_GET['caseid']:0;
$cid = isset($_GET['cid']) ? $_GET['cid']:0;
$page = isset($_GET['page']) ? $_GET['page']:1;


$sql = "SELECT * FROM cases WHERE caseid = $caseid  ORDER BY caseid DESC LIMIT 1";
$result = $db->query($sql);
if($result && $db->num_rows($result)){
    $cases = $db->fetch_one($result);
} else{
    alert("找不到这个案例","cases.php?cid=".$cid."&page=".$page);
}

$case_type = array();
$sql = "SELECT cname FROM case_type WHERE cid =".$cases['cid'];
$result = $db->query($sql);
$case_type = $db->fetch_one($result);

$previd = 0;
$sql = "SELECT * FROM cases WHERE caseid > $caseid  ORDER BY caseid ASC LIMIT 1";
$result = $db->query($sql);
$row = $db->fetch_one($result);
$previd = $row['caseid'];

$nextid = 0;
$sql = "SELECT * FROM cases WHERE caseid < $caseid ORDER BY caseid DESC LIMIT 1";
$result = $db->query($sql);
$row = $db->fetch_one($result);
$nextid = $row['caseid'];

$smarty->assign("case_type",$case_type);
$smarty->assign("cases",$cases);
$smarty->assign("cid",$cid);
$smarty->assign("page",$page);

$smarty->assign("nextid",$nextid);
$smarty->assign("previd",$previd);

$smarty->display("cases_defail.tpl");
$db->close();
?>
